/**
 * @author Guy Sagy
 */

package webSiteDataStore;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class SafeFreeResource
{
    private static final Logger theLogger = Logger.getLogger(SafeFreeResource.class.getName());

    public static void closeResultSet(ResultSet resultSet)
    {
        try
        {
            if (resultSet != null)
            {
                resultSet.close();
            }
        }
        catch(SQLException e)
        {
            theLogger.log(Level.SEVERE, null, e);
        }
    }

    public static void closeStatement(Statement statement)
    {
        try
        {
            if (statement != null)
            {
                statement.close();
            }
        }
        catch(SQLException e)
        {
            theLogger.log(Level.SEVERE, null, e);
        }
    }

    public static void closeConnection(Connection connection)
    {
        try
        {
            if (connection != null)
            {
                connection.close();
            }
        }
        catch(SQLException e)
        {
            theLogger.log(Level.SEVERE, null, e);
        }
    }
}